package edu;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;

public class TCPclient {
    public static void main(String[] args) throws IOException {
        String host = "127.0.0.1";
        int port = 5000;
        try (Socket socket = new Socket(host, port);){
            PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
            out.println("HELLO WORLD");
            BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
            String serverResponse = in.readLine();
            System.out.println("收到服务器回复"+serverResponse);

        }
    }
}
